<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>部门管理</title>

    <link href="${pageContext.request.contextPath}/statics/css/bootstrap.min.css?v=3.3.7" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/statics/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <style>
        body {
            font-family: Arial, Helvetica, sans-serif;
            padding: 20px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            text-align: left;
        }
        table, th, td {
            border: 1px solid #ddd;
            padding: 15px;
        }
        th {
            background-color: #f2f2f2;
        }
        input[type="submit"] {
            background-color: #4CAF50; /* Green */
            color: white;
            padding: 12px 20px;
            margin: 8px 0;
            border: none;
            cursor: pointer;
        }
        a.btn {
            margin: 10px;
        }
        p {
            border: 1px solid #ddd;
            padding: 15px;
            text-align: center;
            background-color: #f2f2f2;
        }
    </style>
    <form action="posts" method="get">
        <label for="post_name">岗位名称</label>
        <select id="post_name" name="postName" class="form-control">
            <option value="">全部岗位</option>
            <option value="董事长">董事长</option>
            <option value="项目经理">项目经理</option>
            <option value="人力资源">人力资源</option>
            <option value="普通员工">普通员工</option>
        </select>
        <button type="submit" class="btn btn-primary">查询</button>
    </form>
</head>
<table class="table table-bordered table-hover">
    <thead>
    <tr>
        <th>岗位ID</th>
        <th>岗位编码</th>
        <th>岗位名称</th>
        <th>显示顺序</th>
        <th>状态</th>
        <th>创建者</th>
        <th>创建时间</th>
        <th>更新者</th>
        <th>更新时间</th>
        <th>备注</th>
        <th>操作</th>
    </tr>
    </thead>

    <c:forEach var="post" items="${list}">
        <tr>
            <td>${post.post_id}</td>
            <td>${post.post_code}</td>
            <td>${post.post_name}</td>
            <td>${post.post_sort}</td>
            <td>
                <c:if test="${post.status   eq 1}">
                    <p>停用</p>
                </c:if>
                <c:if test="${post.status   eq 0}">
                    <p>正常</p>
                </c:if>
            </td>
            <td>${post.create_by}</td>
            <td>${post.create_time}</td>
            <td>${post.update_by}</td>
            <td>${post.update_time}</td>
            <td>${post.remark}</td>
            <td>
                <a  href="add_v4.jsp" class="btn btn-success" onclick="$.operate.add(100)" shiro:hasPermission="system:dept:add">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a href="edit_v4?post_id=${post.post_id}" class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="system:dept:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>

                <a href="JavaScript:void(0)" class="btn btn-danger" style="color: white;" onclick="del(${post.post_id})">
                    <i class="fa fa-remove"></i> 删除
                </a>

            </td>
        </tr>
    </c:forEach>
</table>

<div style="text-align:center;">
    <nav>
        <ul class="pagination">
            <li><a href="list_v4?pageNo=1">首页</a></li>
            <li><a href="list_v4?pageNo=${param.pageNo-1}">上一页</a></li>
            <li><a href="list_v4?pageNo=${param.pageNo+1}">下一页</a></li>
            <li><a href="list_v4?pageNo=${totalPages}">末页</a></li>
        </ul>
    </nav>
    <p>共有 ${totalCount} 条记录</p>
</div>

<script>
    function  del(post_id){
        let con =confirm('确定要删除'+post_id+'吗?')
        if (con){
            location='delete_v4?post_id='+post_id;
        }
    }
</script>
